******************************************
*
*	Article: The Human Costs of the War on Drugs: Attitudes towards Militarization of Security in Mexico
*	Authors: Juan Masullo J., Davide Morisi
*	Journal: Comparative Political Studies
*	Date: 23 March 2023
*
*	This file replicates the following
*	RECODING STUDY 2
*
*	All analyses performed with Stata/SE 14.2 for Windows
******************************************

*Set working directory
*[my working directory]

*Open original dataset without potential identifiers Study 2
use "Replication_CPS\Data\study2_privacy.dta", clear


********
*DV
fre mm_fav
gen dv_att = (mm_fav-1)/6 // rescaled from 0 to 1
label variable dv_att "How favorable on use of military to combat crime"
label de dv 0"not at all" 1"a lot"
label values dv_att dv
ta dv_att
clonevar dv_att_study2 = dv_att
*standardized
egen st_dv_att = std(dv_att)

*Attention check
fre mm_check // 3=correct
recode mm_check (3=1 "correct") (1 2 4 5=0 "not correct"), gen(manip_check)
fre manip_check


********
*Victim of crime (general)
rename vict vict2
fre vict2

*victim of cartel related crime
gen victim_cartel = 0
replace victim_cartel = 1 if vic_fmurder==1
replace victim_cartel = 1 if vic_armedrob==1
replace victim_cartel = 1 if vic_extortion==1
replace victim_cartel = 1 if vic_kidnap==1
replace victim_cartel = 1 if vic_threats==1
label var victim_cartel "Victim of murder/extortion/kidnap/armed rob/threat"
label de victim_cartel 0"no" 1"Yes"
label values victim_cartel victim_cartel
fre victim_cartel // 12%


********
*socio-demographics

*gender
recode gender 1=0 2=1, gen(female)
label de female 0"male" 1"female"
label values female female
fre female

*age
sum age, d
gen age10 = age/10

*education
fre ed_level
recode ed_level (1=1 "none") (2=2 "primary") (3=3 "middle") (4=4 "high school") (5/7=5 "bachelor +"), gen(ed_level5)


********
*other variables

*trust in the army
fre army
*rescaled from 0 to 1
gen trust_army01 = (army-1)/6
label var trust_army01 "How much trust in Army?"
label de trust 0"not at all" 1"absolutely", modify
label values trust_army01 trust
ta trust_army01

*left-right
fre polspectr
clonevar left_right = polspectr
recode polspectr (1/4=1 "left") (5=2 "centre") (6/10=3 "right") (else=99 "dk/refused"), gen(lr4)
fre lr4

*party id
fre strongPartyId weakPartyId mixedPartyId
recode mixedPartyId (9=0 "none") (1=1 "pri") (2=2 "pan") (3=3 "prd") (4=4 "morena") (5/8=5 "other party"), gen(pid5)
fre pid5

*cartel presence categorical
fre cartel_total2017
recode cartel_total2017 (0=0 "no cartel") (1=1 "1 cartel") (2/9=2 "2 or more cartels"), gen(cartel3)


************
*regions
recode DB1_1 (2 3 8 10 25 26=1 "North West") ///
(5 19 28=2 "North East") ///
(6 14 16 18=3 "Centre West") ///
(1 11 24 32=4 "Centre") ///
(13 17 21 22 29=5 "Centre South") ///
(9 15=6 "Estado de Mexico,Federal district") ///
(4 7 12 20 23 27 30 31=7 "South"), gen(regions) 
fre regions


************
*Add variables for merging datasets

*group
clonevar group_study2 = group

*study
gen study = 2 // 2 = study 2

*id
gen id = id_st2+1000


************
save "Replication_CPS\Data\study2_recoded.dta", replace



